#ifndef _DRAWABLE_H_
#define _DRAWABLE_H_

#include <SERender/Resourses/Mesh.h>
#include <SERender/Resourses/Material.h>
#include <SECore/ResourcePayload.h>
namespace SEngine
{
    class Renderer;
    
    enum DrawAPIType
    {
        DrawElements,
        DrawArrays,
    };

    struct RenderOption
    {
        ElemMode mode{TRIANGLES};
        DrawAPIType api{DrawElements};
        size_t instanceCount{1};
    };

    class Drawable 
    {
    public:
        virtual ~Drawable() = default;
        void Draw(Renderer & renderer);
        
        Drawable & SetMesh(std::shared_ptr<Mesh> mesh);
        Drawable & SetMaterial(ResRef<Material> material);
        ResRef<Material> GetMaterial() { return m_material; }
        void SetMode(ElemMode mode) { m_renderOpt.mode = mode; }
        ElemMode GetMode() { return m_renderOpt.mode; }
        void SetAPIType(DrawAPIType type) { m_renderOpt.api = type; }
        void SetInstanceCount(size_t count) { m_renderOpt.instanceCount = count; }

        bool IsValid() { return m_mesh && m_material; }

    protected:
        std::shared_ptr<Mesh> m_mesh;
        ResRef<Material> m_material;
        RenderOption m_renderOpt;
    };
} // namespace SEngine


#endif